<?php
	// ----------------------------------------------------
	// Beschreibung Skript:
	//   Erzeugt einen neuen Benutzer und speichert diesem.
	//
	// ----------------------------------------------------
	// Änderungen:
	//
	// ----------------------------------------------------

	
	// ------------------------------------------------------
	// Initialisiert das Skript.
	// ------------------------------------------------------  
	require_once 'loader.php';

	// ------------------------------------------------------
	// Header laden.
	// ------------------------------------------------------
	include 'header.php';
	
	// ------------------------------------------------------
	// Benutzerdaten laden.
	// ------------------------------------------------------  
	// Load data.
	$arrLabel = Array('Vorname', 'Name', 'Geb', 'Adresse', 'PLZ', 'Ort', 'Tel-P', 'Tel-G', 'Mobile', 'E-Mail-P', 'E-Mail-G', 'Webseite-P', 'Webseite-G');
	//
	print('<form Action="get_user.php" method="post">'."\n");
	print('<input type="hidden" name="Action" value="newMember">'."\n");
	print('<table>'."\n");
	print('  <tbody>'."\n");
	print('    <tr>'."\n");
	print('      <td width="120">&nbsp;</td>'."\n");
	print('      <td width="150">Anrede:</td>'."\n");
	print('      <td width="150" class="title">'."\n");
	print('        <select name="Title" size="1">'."\n");
	print('          <option value="Herr">Herr</option>'."\n");
	print('          <option value="Frau">Frau</option>'."\n");
	print('        </select>'."\n");
	print('      </td>'."\n");
	print('    </tr>'."\n");
	print('    <tr>'."\n");
	print('      <td valign="top" rowspan="'.(count($arrLabel)+1).'" width="120">'."\n");
	print('        <img src="'.$Member->ImagePath.'" alt="'.$Member->UserName.'" width="'.strval($Member->ImageWidth).'" height="'.strval($Member->ImageHeigth).'"><br />'."\n");
	print('      </td>'."\n");
	print('      <td width="150">ExternalUserID:</td>'."\n");
	print('      <td><input name="ExternalUserID" type="text" size="30" maxlength="30" /></td>'."\n");
	print('    </tr>'."\n");
	For ($ix = 0; $ix < count($arrLabel); $ix++) {
		print('    <tr>'."\n");
		print('      <td>'.$arrLabel[$ix].':</td>'."\n");
		print('      <td><input name="'.$arrLabel[$ix].'" type="text" size="30" maxlength="30" /></td>'."\n");
		print('    </tr>'."\n");
	}
	print('  </tbody>'."\n");
	print('</table>'."\n");
	print('</form>'."\n");
	print("<br />"."\n");

	// ------------------------------------------------------
	// Memberdata laden.
	// ------------------------------------------------------
	// Print committee, job and License data.
	$arrLabel = Array('Familienflag', 'Lizenzen', 'User-Status', 'Aufgaben', 'Vorstand');
	$arrMemberStates = $UserDb->getMemberStates();
	$arrAssociationTypes = $UserDb->getAssociationTypes();
	$arrJobTypes = $UserDb->getJobTypes();
	$arrCommitteeTaskTypes = $UserDb->getCommitteeTaskTypes();
	//
	print('<table>'."\n");
	print('  <tbody>'."\n");

	// MemberState:
	print('    <tr>'."\n");
	print('      <td width="120">&nbsp;</td>'."\n");
	print('      <td width="150">Mitgliederstatus:</td>'."\n");
	print('      <td width="150" class="memberstate"><select name="MemberState" size="1">'."\n");
	foreach ($arrMemberStates as $key=>$value) {
		if ('Anwärter' == $value) {
			print('      <option value="'.$key.'-'.$value.'" selected="selected">'. $value .'</option>'."\n");
		} else {
			print('      <option value="'.$key.'-'.$value.'">'. $value .'</option>'."\n");
		}
	}
		print('      </select></td>'."\n");
	print('    </tr>'."\n");

	// FamilyFlag:
	print('    <tr>'."\n");
	print('      <td width="120">&nbsp;</td>'."\n");
	print('      <td width="150">Familienflag:</td>'."\n");
	print('      <td width="150" class="familyflag"><select name="FamilyFlag" size="1">'."\n");
	print('      <option value="1">Ja</option>'."\n");
	print('      <option value="0" selected="selected">Nein</option>'."\n");
	print('      </select></td>'."\n");
	print('    </tr>'."\n");

	// Licenses:
	print('    <tr>'."\n");
	print('      <td width="120">&nbsp;</td>'."\n");
	print('      <td width="150" valign="top">Lizenzen:</td>'."\n");
	print('      <td width="150" class="license">'."\n");
	foreach ($arrAssociationTypes as $key=>$value) {
		print('      <div>'."\n");
		print('        <span style="display: inline-block; width: 60px;"><input type="checkbox" name="AssociationTypes[]" value="'.$value.'">'. $value .'</span>'."\n");
		print('        <input name="'.strtolower($value).'_license" type="text" size="10" maxlength="10"'."\n");
		print('      </div>'."\n");
	}
	print('      </td>'."\n");
	print('    </tr>'."\n");

	// Jobs:
	print('    <tr>'."\n");
	print('      <td width="120">&nbsp;</td>'."\n");
	print('      <td width="150" valign="top">Aufgaben:</td>'."\n");
	print('      <td width="150" class="jobs">'."\n");
	foreach ($arrJobTypes as $key=>$value) {
		print('      <input type="checkbox" name="Jobs[]" value="'.$key.'-'.$value.'">'. $value .'<br />'."\n");
	}
	print('      </td>'."\n");
	print('    </tr>'."\n");

	// CommitteeTasks:
	print('    <tr>'."\n");
	print('      <td width="120">&nbsp;</td>'."\n");
	print('      <td width="150" valign="top">Vorstand:</td>'."\n");
	print('      <td width="150" class="committeetask">'."\n");
	foreach ($arrCommitteeTaskTypes as $key=>$value) {
		print('      <input type="checkbox" name="CommitteeTasks[]" value="'.$key.'-'.$value.'">'. $value .'<br />'."\n");
	}
	print('      </td>'."\n");
	print('    </tr>'."\n");

	// User-State:
	print('    <tr>'."\n");
	print('      <td width="120">&nbsp;</td>'."\n");
	print('      <td width="150">User-Status:</td>'."\n");
	print('      <td width="150" class="userstate"><select name="State" size="1">'."\n");
	print('      <option value="1" selected="selected">Aktiv</option>'."\n");
	print('      <option value="0">Inaktiv</option>'."\n");
	print('      </select></td>'."\n");
	print('    </tr>'."\n");

	print('    <tr>'."\n");
	print('      <td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'."\n");
	print('    </tr>'."\n");

	print('    <tr>'."\n");
	print('      <td>&nbsp;</td><td>&nbsp;</td><td align="right">'."\n");
	print('      	<input type="button" value="Abbrechen" onclick="location.href = \'get_user.php\'">'."\n");
	print('      	<span style="width:10pt;">&nbsp;</span>'."\n");
	print('      	<input type="submit" value="Senden">'."\n");
	print('      </td>'."\n");
	print('    </tr>'."\n");
	print('  </tbody>'."\n");
	print('</table>'."\n");
	print('</form>'."\n");
	
	
	// ------------------------------------------------------
	// Footer laden.
	// ------------------------------------------------------
	include 'footer.php';
?>